package com.inmobi.commons.thinICE.cellular;

import android.content.Context;
import android.telephony.CellLocation;
import android.telephony.TelephonyManager;
import android.telephony.cdma.CdmaCellLocation;
import android.telephony.gsm.GsmCellLocation;

public final class CellUtil
{
  private static final String[] a = { "android.permission.ACCESS_COARSE_LOCATION" };

  private static int[] a(String paramString)
  {
    int[] arrayOfInt = { -1, -1 };
    if ((paramString == null) || (paramString.equals("")))
      return arrayOfInt;
    try
    {
      int i = Integer.parseInt(paramString.substring(0, 3));
      int j = Integer.parseInt(paramString.substring(3));
      arrayOfInt[0] = i;
      arrayOfInt[1] = j;
      return arrayOfInt;
    }
    catch (IndexOutOfBoundsException localIndexOutOfBoundsException)
    {
      return arrayOfInt;
    }
    catch (NumberFormatException localNumberFormatException)
    {
    }
    return arrayOfInt;
  }

  public static CellOperatorInfo getCellNetworkInfo(Context paramContext)
  {
    CellOperatorInfo localCellOperatorInfo = new CellOperatorInfo();
    TelephonyManager localTelephonyManager = (TelephonyManager)paramContext.getSystemService("phone");
    int[] arrayOfInt1 = a(localTelephonyManager.getNetworkOperator());
    localCellOperatorInfo.currentMcc = arrayOfInt1[0];
    localCellOperatorInfo.currentMnc = arrayOfInt1[1];
    int[] arrayOfInt2 = a(localTelephonyManager.getSimOperator());
    localCellOperatorInfo.simMcc = arrayOfInt2[0];
    localCellOperatorInfo.simMnc = arrayOfInt2[1];
    return localCellOperatorInfo;
  }

  public static String getCurrentServingCell(Context paramContext)
  {
    TelephonyManager localTelephonyManager = (TelephonyManager)paramContext.getSystemService("phone");
    int[] arrayOfInt = a(localTelephonyManager.getNetworkOperator());
    CellLocation localCellLocation = localTelephonyManager.getCellLocation();
    if ((localCellLocation == null) || (arrayOfInt[0] == -1))
      return null;
    String str1 = String.valueOf(arrayOfInt[0]);
    String str2 = String.valueOf(arrayOfInt[1]);
    if ((localCellLocation instanceof CdmaCellLocation))
    {
      CdmaCellLocation localCdmaCellLocation = (CdmaCellLocation)localCellLocation;
      int k = localCdmaCellLocation.getNetworkId();
      int m = localCdmaCellLocation.getBaseStationId();
      int n = localCdmaCellLocation.getSystemId();
      if ((k != -1) && (m != -1) && (n != -1))
      {
        String str5 = Integer.toHexString(k);
        String str6 = Integer.toHexString(m);
        String str7 = Integer.toHexString(n);
        return str1 + "-" + str2 + "-" + str5 + "-" + str6 + "-" + str7;
      }
    }
    else
    {
      GsmCellLocation localGsmCellLocation = (GsmCellLocation)localCellLocation;
      int i = localGsmCellLocation.getCid();
      int j = localGsmCellLocation.getLac();
      if ((i != -1) && (j != -1))
      {
        String str3 = Integer.toHexString(j);
        String str4 = Integer.toHexString(i);
        return str1 + "-" + str2 + "-" + str3 + "-" + str4;
      }
    }
    return null;
  }

  public static boolean hasGetCurrentServingCellPermission(Context paramContext)
  {
    String[] arrayOfString = a;
    int i = arrayOfString.length;
    for (int j = 0; j < i; j++)
      if (paramContext.checkCallingOrSelfPermission(arrayOfString[j]) != 0)
        return false;
    return true;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.inmobi.commons.thinICE.cellular.CellUtil
 * JD-Core Version:    0.6.2
 */